import axios from 'axios';

export interface CarStationItem {
  id?: number | string;
  stationName: string;
  province: string;
  city: string;
  district?: string;
  address: string;
  longitude?: number;
  latitude?: number;
  contactPerson?: string;
  contactPhone?: string;
  stationType: number;
  businessHours?: string;
  facilities?: string;
  status: number;
  sortOrder?: number;
  createTime?: string;
  updateTime?: string;
  createBy?: string;
  updateBy?: string;
  remark?: string;
}

export interface CarStationPageData {
  records: CarStationItem[];
  total: number;
  size: number;
  current: number;
  pages: number;
}

export interface ApiResponse<T> {
  code: number;
  message: string;
  data: T;
}

// 分页查询汽车站点列表
export function getCarStationPage(params: {
  current: number;
  size: number;
  stationName?: string;
  province?: string;
  city?: string;
  status?: number;
  partnerId?: number;
}) {
  return axios.get<ApiResponse<CarStationPageData>>('/api/car/station/page', {
    params,
  });
}

// 获取汽车站点详情
export function getCarStationDetail(id: number | string) {
  return axios.get<ApiResponse<CarStationItem>>(`/api/car/station/${id}`);
}

// 新增汽车站点
export function addCarStation(data: Omit<CarStationItem, 'id' | 'createTime' | 'updateTime'>) {
  return axios.post<ApiResponse<CarStationItem>>('/api/car/station', data);
}

// 更新汽车站点
export function updateCarStation(data: CarStationItem) {
  return axios.put<ApiResponse<boolean>>('/api/car/station', data);
}

// 删除汽车站点
export function deleteCarStation(id: number | string) {
  return axios.delete<ApiResponse<boolean>>(`/api/car/station/${id}`);
} 